from selenium.webdriver.common.by import By
from pages.base_page import BasePage
import allure
import logging

logger = logging.getLogger(__name__)

class HomePage(BasePage):
    """首页页面对象"""
    # 页面元素定位器（元组格式：(定位方式, 定位值)）
    LOGIN_BTN = (By.XPATH, "//a[contains(text(),'登陆')]")
    REGISTER_BTN = (By.XPATH, "//a[contains(text(),'注册')]")
    home=(By.XPATH, "//a[contains(text(),'首页')]")
    user_center=(By.XPATH, "//a[contains(text(),'| 用户中心')]")
    picture=(By.XPATH,"//img[@src='/static/img/title.png']")
    search_k=(By.ID,'search')
    search_button=(By.ID,'search-button')
    fabu = (By.XPATH, "//a[contains(text(),'发布闲置')]")
    xzsj=(By.XPATH, "//a[@class='btn btn-link'][contains(text(),'闲置书籍')]")
    smdz=(By.XPATH, "(//a[@class='btn btn-link'][contains(text(),'数码电子')])[1]")

    def __init__(self, driver):
        super().__init__(driver)
        self.driver.get("http://127.0.0.1:8000/")  # 打开首页

    def click_login_btn(self):
        """点击登录按钮"""
        self.click(*self.LOGIN_BTN)
